<?php
require_once("admin_global.php");    //加载后台全局调用类文件
$db->Get_user_shell_check($uid,$shell);   //后台登录控制

//查询出一级导航栏目，存储到数组中
$sql="SELECT * FROM category WHERE catePID=0";
$query=$db->query($sql);
while($row=$db->fetch_array($query)){
    $data[]=$row;
}
//定义一个数组，存储栏目类型图标
$images=array("images/folder.png","images/folder_book.png","images/document.png");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>管理栏目分类</title>
        <link rel="stylesheet" href="css/right.css" type="text/css" /> 
        <script src="js/jquery-1.12.4.min.js" type="text/javascript"></script>
        <script src="js/bggl.js" type="text/javascript"></script>
    </head>
    <script>
        function delCate_check() {
            if(window.confirm("删除栏目将同时删除栏目下的所有文章，你确定要删除吗？")){
                return true;
            }else{
                return false;
            }
        }
    </script>
    <body>
        <div id="right_main">
            <div class="right_content">
                <div class="right_top_menu">
                    <h3>
                        您当前的位置：后台 > 栏目管理 > 管理栏目分类
                    </h3>
                </div>
                <div class="right_center_content">
                    <form id="form1" method="post" action="">
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                            <tr>
                                <td valign="top" >
                                    <div class="txl_search"></div>
                                    <table cellpadding="0" id= "table1" cellspacing="0" border="0" width="100%" class="fg_table txl_table" id="table1">
                                        <tr>
                                            <th width="5%">栏目ID</th>
                                            <th width="15%">栏目名称</th>
                                            <th width="15%">栏目风格</th>
                                            <th width="10%">导航位置</th>
                                            <th width="7%">是否显示</th>
                                            <th width="8%">链接新闻ID</th>
                                            <th width="5%">栏目排序</th>
                                            <th width="10%">创建日期</th>
                                            <th width="10%">栏目说明</th>
                                            <th width="5%">修改</th>
                                            <th width="5%">删除</th>
                                        </tr>
                                        <?php foreach ($data as $row){; ?>
                                        <tr>
                                            <td><?php echo $row['id']; ?></td>
                                            <?php
                                            $id=$row['id'];
                                            $sql1="SELECT * FROM category WHERE catePID=$id";
                                            $query1=$db->query($sql1);
                                            $num=$db->db_num_rows($query1);
                                            if($num>0){
                                                $image=$images[0];
                                                $link="listChildCate.php?id=$id";
                                            }else{
                                                $image=$images[1];
                                                $link="listNews.php?id=$id";
                                            }
                                            //查询栏目风格
                                            $sql2="SELECT cateStyleName FROM category AS a,catestyle AS b WHERE b.cateStyleID=a.cateStyleID AND a.id=$id";
                                            $query2=$db->query($sql2);
                                            $result2=$db->fetch_array($query2);
                                            $cateStyleName=$result2['cateStyleName'];
                                            //是否显示栏目
                                            if($row['isShow']==1){
                                                $isShow="是";
                                            }else{
                                                $isShow="否";
                                            }
                                            ?>
                                            <td><a href="<?php echo $link; ?>"><img src="<?php echo $image; ?>"  width="16" height="16" border="0"> </a><?php echo $row['cateName']; ?></td>
                                            <td><?php echo $cateStyleName; ?></td>
                                            <td><?php echo $row['cateNavigation']; ?></td>
                                            <td><?php echo $isShow; ?></td>
                                            <td><?php echo $row['linkNewsID']; ?></td>
                                            <td><?php echo $row['cateIndex']; ?></td>
                                            <td><?php echo $row['cateCreateDate']; ?></td>
                                            <td><?php echo $row['cateRemark']; ?></td>
                                            <td><a href="editCate.php?id=<?php echo $id; ?>"><img src="images/adj_bg.gif" width="15" height="15" border="0" /></a></td>
                                            <td><a href="delCate.php?id=<?php echo $id; ?>" onclick="javascript:return delCate_check();"><img src="images/del2.gif" width="16" height="16" border="0" /></a></td>
                                        </tr>
                                        <?php }; ?>
                                    </table>
                                </td>
                            </tr>   
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>
